﻿using System;
using System.Text;
using System.Data.Common;
using System.Data; 
using System.Collections.Generic;
using System.Web.Profile;
using System.Web.Security; 
using seoWebApplication.st.SharkTankDAL; 
using seoWebApplication.st.SharkTankDAL.entObject;
using seoWebApplication.st.SharkTankDAL.Framework;
using seoWebApplication.st.SharkTankDAL.dataObject;
using System.Linq;
using System.Web;
 

namespace seoWebApplication.st.SharkTankDAL
{

    public class CommerceAccessor
    {


        /// <summary>
        /// Wraps tax data
        /// </summary>
        public struct TaxInfo
        {
            public int TaxID;
            public int webstore_id;
            public string TaxType;
            public double TaxPercentage;
        }
        /// <summary>
        /// Wraps shipping data
        /// </summary>
        public struct ShippingInfo
        {
            public int ShippingID;
            public int webstore_id;
            public string ShippingType;
            public double ShippingCost;
            public int ShippingRegionId;
        }

        public static List<ShippingInfo> GetShippingInfo(int shippingRegionId)
        {
   
            
            // get a configured DbCommand object
            DbCommand comm = GenericDataAccess.CreateCommand();
            // set the stored procedure name
            comm.CommandText = "CommerceLibShippingGetInfo";
            // create a new parameter
            DbParameter param = comm.CreateParameter();
            param.ParameterName = "@ShippingRegionId";
            param.Value = shippingRegionId;
            param.DbType = DbType.Int32;
            comm.Parameters.Add(param);
            // obtain the results
            DataTable table = GenericDataAccess.ExecuteSelectCommand(comm);
            List<ShippingInfo> result = new List<ShippingInfo>();
            foreach (DataRow row in table.Rows)
            {
                ShippingInfo rowData = new ShippingInfo();
                rowData.ShippingID = int.Parse(row["ShippingId"].ToString());
                rowData.ShippingType = row["ShippingType"].ToString();
                rowData.ShippingCost =
                double.Parse(row["ShippingCost"].ToString());
                rowData.ShippingRegionId = shippingRegionId;
                result.Add(rowData);
            }
            return result;
        }

      
    }

   

   

   

    
}
